Class Nur.MNISV3.Service.Config Extends %RegisteredObject [ Not ProcedureBlock ]
{

/// Creator:      fengliang
/// CreatDate:    2021-03-16
/// Description:  获取主界面模块配置  
/// Other         w ##class(Nur.MNISV3.Service.Config).GetMainConfig("8","23")
ClassMethod GetMainConfig(locId, groupId)
{
    n (locId,groupId)
    s ^EH("GetMainConfigV3")=$lb(locId,groupId)
    s $zt="errGetMainConfig"
    s msg="",msgcode="999999",status="0" //定义初始值
    s mainObj=..GetModulSetByMenu(locId,groupId)
    s screenParts=..GetOrderFilterObject(locId,groupId)
    s generalSetting=..GetGeneralSetting("",locId)
    s startDate=generalSetting.GetAt("SchStartDate"),startTime=generalSetting.GetAt("SchStartTime")
    s endDate=generalSetting.GetAt("SchEndDate"),endTime=generalSetting.GetAt("SchEndTime")
    s stdatetime=$zd(+$h+startDate,3)_" "_startTime
    s enddatetime=$zd(+$h+endDate,3)_" "_endTime
    s voiceFlag=generalSetting.GetAt("VoiceFlag")
    s curDateTime=$zd(+$h,3)_" "_$zt($p($h,",",2))
    s configFlags=..GetConfigFlags("",locId)
    
    s json=##class(%ArrayOfDataTypes).%New()
    d json.SetAt($g(msg),"msg")
    d json.SetAt($g(msgcode),"msgcode")
    d json.SetAt("2","scantimes")
    d json.SetAt($g(status),"status")
    d json.SetAt($g(mainObj),"mainList")
    d json.SetAt($g(screenParts),"screenParts")
    d json.SetAt($g(stdatetime),"schStDateTime")  
    d json.SetAt($g(enddatetime),"schEnDateTime")
    d json.SetAt($g(curDateTime),"curDateTime")
    d json.SetAt(voiceFlag,"ifVoice")
    d json.SetAt(configFlags,"configFlags")
    q ##class(Nur.MNISV3.Common.JSON).Encode(json)    
errGetMainConfig
    s msg=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJson(msg,"100010","-1")
}

/// Creator:        LMS
/// CreatDate:      2019-09-18
/// Description:    获取筛选条件配置
/// Input：          
/// Return：      
/// Other           w ##class(Nur.MNISV3.Service.Config).GetScreenConfig()
ClassMethod GetScreenConfig(locId = "")
{
    k LMSTEMP
    //"exeFlag|未执行!已执行|Single|执行状态|^oecprDesc|长期!临时|Single|优先级|DefaultSee!PSD!BLD^ordType|药品!检验!其他|Multiple|类型|DefaultSee^phcinDesc|注射!IV!DV|Multiple|用法|WZX!"
    //做成配置页面，这四种类型的筛选条件，每个筛选条件对应（医嘱查询界面显示的单据），勾选哪个单据哪个单据进行这层筛选
    s keyCodeStr="exeFlag|oecprDesc|ordType"  //|phcinDesc
    s keyValueStr="未执行!已执行|长期!临时|药品!检验!其他"  //|注射!IV!DV
    s keyTypeStr="Single|Single|Multiple"  //|Multiple
    s keyDescStr="执行状态|优先级|类型"  //|用法
    s keyPerStr="DefaultSee!PSD!BLD|DefaultSee!PSD!BLD|DefaultSee!PSD!BLD"  //|DefaultSee!PSD!BLD
    s len=$l(keyCodeStr,"|")
    f i=1:1:len
    {
        s LMSTEMP(0)=""
        s keyCode=$p(keyCodeStr,"|",i)
        s keyValue=$p(keyValueStr,"|",i)
        s keyType=$p(keyTypeStr,"|",i)
        s keyDesc=$p(keyDescStr,"|",i)
        s keyPer=$p(keyPerStr,"|",i)
        s LMSTEMP(i)=keyCode_"|"_keyValue_"|"_keyType_"|"_keyDesc_"|"_keyPer
        s LMSTEMP(i)=LMSTEMP(i)_"^"_LMSTEMP(i-1)
    }
    
    q LMSTEMP(len)
}

/// w ##class(Nur.JSON).Encode(##class(Nur.MNISV3.Service.Config).GetOrderFilterObject("8","23"))
ClassMethod GetOrderFilterObject(locId = "", groupId = "")
{
    n (locId,groupId)
    k codeArrDefault,dataArrDefault,codeArr,dataArr,configArr,sheetArrSet
    s hospId=##class(Nur.MNISV3.Service.Session).GetLocHospID(locId)
    s codeArrDefault(1)="execFlag"
    s codeArrDefault(2)="oecprDesc"
    s codeArrDefault(3)="ordType"
    s dataArrDefault("execFlag")=$lb("","执行类型","DefaultSee!PSD!BLD","未执行!已执行","Single","execFlag","2","common")
    s dataArrDefault("oecprDesc")=$lb("","优先级","DefaultSee!PSD!BLD","长期!临时","Single","oecprDesc","2","common")
    s dataArrDefault("ordType")=$lb("","类型","DefaultSee!PSD!BLD","药品!检验!其他","Multiple","ordType","2","common")
    m codeArr=codeArrDefault
    s idF=0 f  s idF=$o(^CF.NUR.MNIS.ExecConfigD(idF)) q:(idF="")  d
    .s dataF=$g(^CF.NUR.MNIS.ExecConfigD(idF))
    .s codeF=$lg(dataF,6)
    .s hospIdF=$lg(dataF,7)
    .s locIdF=$lg(dataF,8)
    .i (locIdF="common") s locIdF=0
    .q:(codeF="")||(hospIdF="")||(locIdF="")
    .s dataArr(codeF,hospIdF,locIdF)=dataF
    .s findF=0
    .s typeF="" f  s typeF=$o(codeArr(typeF)) q:(typeF="")||(findF=1)  d
    ..i (codeF=$g(codeArr(typeF))) s findF=1
    .q:(findF=1)
    .s typeF=$o(codeArrDefault(""),-1)
    .s codeArr(typeF+1)=codeF
    s codeF="" f  s codeF=$o(dataArr(codeF)) q:(codeF="")  d
    .s hospIdF=+hospId
    .i ('$d(dataArr(codeF,hospIdF))) s hospIdF=$o(dataArr(codeF,""))
    .q:(hospIdF="")
    .s locIdF=+locId
    .i ('$d(dataArr(codeF,hospIdF,locIdF))) s locIdF=$o(dataArr(codeF,hospIdF,""))
    .q:(locIdF="")
    .s configArr(codeF)=$g(dataArr(codeF,hospIdF,locIdF))
    s typeF="" f  s typeF=$o(codeArr(typeF)) q:(typeF="")  d
    .s codeF=$g(codeArr(typeF))
    .i ('$d(configArr(codeF))) s configArr(codeF)=$g(dataArrDefault(codeF))
    .s dataF=$g(configArr(codeF))
    .s sheetStrF=$lg(dataF,3)
    .q:(sheetStrF="")
    .s sheetLenF=$l(sheetStrF,"!")
    .f sheetIndF=1:1:sheetLenF d
    ..s sheetNodF=$p(sheetStrF,"!",sheetIndF)
    ..s sheetCodF=sheetNodF
    ..q:(sheetCodF="")
    ..s sheetArrSet(sheetCodF)=""
    s sheetStr=..GetSheetStr(groupId,hospId,locId)
    s configStr=""
    s typeF="" f  s typeF=$o(codeArr(typeF)) q:(typeF="")  d
    .s codeF=$g(codeArr(typeF))
    .s dataF=$g(configArr(codeF))
    .s sheetStrF=$lg(dataF,3)
    .q:(sheetStrF="")
    .s sheetStrJ=""
    .k sheetArrF
    .s sheetLenF=$l(sheetStrF,"!")
    .f sheetIndF=1:1:sheetLenF d
    ..s sheetNodF=$p(sheetStrF,"!",sheetIndF)
    ..s sheetCodF=sheetNodF
    ..q:(sheetCodF="")
    ..q:(codeF="oecprDesc")&&(sheetCodF["JYD")
    ..q:(codeF="oecprDesc")&&(sheetCodF["JCD")
    ..q:(codeF="ordType")&&(sheetCodF["JYD")
    ..q:(codeF="ordType")&&(sheetCodF["JCD")
    ..q:($d(sheetArrF(sheetCodF)))
    ..s sheetArrF(sheetCodF)=""
    ..i (sheetStrJ'="") s sheetStrJ=sheetStrJ_"!"
    ..s sheetStrJ=sheetStrJ_sheetCodF
    .s sheetLen=$l(sheetStr,"^")
    .f sheetInd=1:1:sheetLen d
    ..s sheetNod=$p(sheetStr,"^",sheetInd)
    ..s sheetCod=$p(sheetNod,"@",2)
    ..q:(sheetCod="")
    ..q:($d(sheetArrF(sheetCod)))
    ..q:($d(sheetArrSet(sheetCod)))
    ..s sheetArrF(sheetCod)=""
    ..i (sheetStrJ'="") s sheetStrJ=sheetStrJ_"!"
    ..s sheetStrJ=sheetStrJ_sheetCod
    .q:(sheetStrJ="")
    .s nameF=$lg(dataF,2)
    .s optionF=$lg(dataF,4)
    .s sheetStrF=sheetStrJ
    .s singleF=$lg(dataF,5)
    .s configNod=codeF_"|"_optionF_"|"_singleF_"|"_nameF_"|"_sheetStrF
    .i (configStr'="") s configStr=configStr_"^"
    .s configStr=configStr_configNod
    s configs=##class(%ListOfDataTypes).%New()
    s configLen=$l(configStr,"^")
    f configInd=1:1:configLen d
    .s configNod=$p(configStr,"^",configInd)
    .s codeF=$p(configNod,"|",1)
    .s optionF=$p(configNod,"|",2)
    .s singleF=$p(configNod,"|",3)
    .s nameF=$p(configNod,"|",4)
    .s sheetStrF=$p(configNod,"|",5)
    .s commonF="false"
    .i (codeF="exeFlag") s commonF="true"
    .q:(codeF="")
    .s config=##class(%ArrayOfDataTypes).%New()
    .d config.SetAt(commonF,"commonKey")
    .d config.SetAt(codeF,"keyCode")
    .d config.SetAt(optionF,"keyValue")
    .d config.SetAt(singleF,"keyType")
    .d config.SetAt(nameF,"keyDesc")
    .d config.SetAt(sheetStrF,"danjuStr")
    .d configs.Insert(config)
    q configs
}

/// Creator:        fengliang
/// CreatDate:      2018-12-26
/// Description:    获取主界面模块配置    
/// Other           w ##class(Nur.MNISV3.Service.Config).GetModulSet()
ClassMethod GetModulSet(locId = "", groupId = "")
{
    n (locId,groupId)
    ;s ^MML("getModulSet")=$lb(locId,groupId)
    i locId="" s locId="common"
    i $d(^DHCNurPdaLocComFlag("Com",locId)) s commonFlag=^DHCNurPdaLocComFlag("Com",locId)
    e  s commonFlag="Y"     
    s HospitalRowId=$p($G(^CTLOC(+locId)),"^",22)
    i commonFlag="Y" s locId="common"_HospitalRowId     
    s mainObj=##class(%ListOfDataTypes).%New()
    s id=""
    f  s id=$o(^CT.NUR.MNIS.MainModuleD(id)) q:id=""  d
    .s moduleData=^CT.NUR.MNIS.MainModuleD(id)
    .s moduleCode=$listget(moduleData,3)
    .s sort=$listget(moduleData,4)
    .s canFlag=$listget(moduleData,5)
    .i (canFlag) b
    .q:canFlag="N"
    .//默认显示标准数据，如果按科室设置之后显示科室配置
    .s moduleLocId=$o(^CT.NUR.MNIS.MainModuleByLocI("locCodeIndex"," "_$ZCVT(locId,"U")," "_$ZCVT(moduleCode,"U"),""))
    .i moduleLocId'="" d
    ..s moduleLocData=$g(^CF.NUR.MNIS.MainModuleByLocD(moduleLocId))
    ..s sort=$listget(moduleLocData,4)
    .i sort="" s sort=999999
    .s moduleID(sort,id)=1
    s sort=""
    f  s sort=$o(moduleID(sort)) q:sort=""  d
    .s moduleID=""
    .f  s moduleID=$o(moduleID(sort,moduleID)) q:moduleID=""  d
    ..s moduleData=$g(^CT.NUR.MNIS.MainModuleD(moduleID))
    ..s moduleName=$listget(moduleData,2)
    ..s moduleCode=$listget(moduleData,3)
    ..s moduleSort=$listget(moduleData,4)
    ..s moduleShowFlag="Y"
    ..//默认显示标准数据，如果按科室设置之后显示科室配置
    ..s moduleLocId=$o(^CF.NUR.MNIS.MainModuleByLocI("locCodeIndex"," "_$ZCVT(locId,"U")," "_$ZCVT(moduleCode,"U"),""))
    ..i moduleLocId'="" d
    ...s moduleLocData=$g(^CF.NUR.MNIS.MainModuleByLocD(moduleLocId))
    ...s moduleName=$listget(moduleLocData,2)
    ...s moduleSort=$listget(moduleLocData,4)
    ...s moduleShowFlag=$listget(moduleLocData,5)
    ..q:moduleShowFlag="N"
    ..s mainArr=##class(%ArrayOfDataTypes).%New()
    ..d mainArr.SetAt(moduleName,"moduleDesc")
    ..d mainArr.SetAt(moduleCode,"moduleCode")
    ..d mainObj.Insert(mainArr)
    q mainObj
}

/// Creator：      EH
/// CreatDate：    2021-10-27
/// Description:   兼容8.5     
ClassMethod GetSheetStr(groupID, hospitalId = "", locId = "") As %String
{
    n (groupID,hospitalId,locId,%session)
    //Nur.NIS.Service.OrderExcute.QueryOrder
    s ^GRS("GetSheetStr")=$lb(groupID,hospitalId,locId)
    s mainHospID=##class(web.DHCBL.BDP.BDPMappingHOSP).GetDefHospIdByTableName("Nur_IP_ExecuteGroup",hospitalId,"")
    // 获取安全组配置
    s applyBusiness="NurE"
    s byGroupId=$o(^CF.NUR.NIS.ExecuteGroupI("TypeItem",mainHospID," 1"," "_groupID," "_$zcvt(applyBusiness,"U"), ""))
    i (byGroupId="") s byGroupId=$o(^CF.NUR.NIS.ExecuteGroupI("TypeItem",mainHospID," 1"," "_groupID, ""))
    // 获取科室配置
    s byLocId=$o(^CF.NUR.NIS.ExecuteGroupI("TypeItem",mainHospID," 2"," "_locId," "_$zcvt(applyBusiness,"U"), ""))
    i (byLocId="") s byLocId=$o(^CF.NUR.NIS.ExecuteGroupI("TypeItem",mainHospID," 2"," "_locId, ""))
    // 如果科室配置不为空则取科室配置
    i byLocId'="" s byGroupId=byLocId
    i (byGroupId'="") d
    .s byGroupSubId="" f  s byGroupSubId=$o(^CF.NUR.NIS.ExecuteGroupSubD(byGroupId,byGroupSubId)) q:(byGroupSubId="")  d
    ..s data=$g(^CF.NUR.NIS.ExecuteGroupSubD(byGroupId,byGroupSubId))
    ..s sheetId=$lg(data,2)
    ..s default=$lg(data,3)
    ..s obj=##class(CF.NUR.NIS.NurseSheetSet).%OpenId(sheetId)
    ..q:('$isobject(obj))
    ..s code=obj.NSSCode
    ..d obj.%Close()
    ..s sheetStr=$g(sheetStr)_"^"_hospitalId_"@"_code
    q $g(sheetStr)
}

/// Creator：      fengliang 
/// CreatDate：    2020-07-31 
/// Description:   通过类中的枚举字段生成option 
/// Others：        w ##class(Nur.MNISV3.Service.Config).GetOptionOfProperty("Nur.NIS.TaskRecord","NTRECStatus")
ClassMethod GetOptionOfProperty(className, propertyName)
{
    n (className,propertyName,%request,%session)
    s propertyDefine=##class(%Dictionary.PropertyDefinition).%OpenId(className_"||"_propertyName)
    q:propertyDefine="" "未找到该配置"
    s desc=propertyDefine.Description
    s paprameters=propertyDefine.Parameters
    s displays=paprameters.GetAt("DISPLAYLIST")
    i (desc'="")&(desc[",") s displays=desc
    s values=paprameters.GetAt("VALUELIST")
    q:(displays="")||(values="") "未找到该配置"
    s rs=##class(%ListOfDataTypes).%New()
    s optionCount=$LENGTH(values,",")
    for i=1:1:optionCount
    {
        i $p(displays,",",i)'=""
        {
            s option=##class(%ArrayOfDataTypes).%New()
            d option.SetAt($p(displays,",",i),"text")
            d option.SetAt($p(values,",",i),"value")
            d rs.Insert(option)
        }
    }
    q rs
}

ClassMethod GetLogonConfig()
{
    n
    s $zt="errGetLogonConfig"
    s msg="",msgcode="999999",Status="0" //定义初始值
    s json=##class(%ArrayOfDataTypes).%New()
    s broadcastList=##class(%ListOfDataTypes).%New()
    
    s Action="" f  s Action=$o(^CF.NUR.MNISV3.AndroidBroadcastI("ActionDecode",Action)) q:Action=""  d
    .s Decode="" f  s Decode=$o(^CF.NUR.MNISV3.AndroidBroadcastI("ActionDecode",Action,Decode)) q:Decode=""  d
    ..s rw="" f  s rw=$o(^CF.NUR.MNISV3.AndroidBroadcastI("ActionDecode",Action,Decode,rw)) q:rw=""  d
    ...s a=##class(CF.NUR.MNISV3.AndroidBroadcast).%OpenId(rw)
    ...s item=##class(%ArrayOfDataTypes).%New()
    ...d item.SetAt(a.Name,"Name")
    ...d item.SetAt(a.Action,"Action")
    ...d item.SetAt(a.Decode,"Decode")
    ...d broadcastList.Insert(item)
    s loginFlags=..GetLoginFlags() // EH 2022-04-08 登陆前设置放在广播
    i (loginFlags.GetAt("serverIPFlag")) d
    .s serverIP="当前连接："_##class(ext.util.String).ServerIP()
        
    d json.SetAt($g(msg),"msg")
    d json.SetAt($g(msgcode),"msgcode")
    d json.SetAt($g(Status),"status")
    d json.SetAt($g(broadcastList),"broadcastList")
    d json.SetAt($g(loginFlags),"loginFlags")
    d json.SetAt($g(serverIP),"serverIP")
    q ##class(Nur.MNISV3.Common.JSON).Encode(json)
errGetLogonConfig
    s msg=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJson(msg,"100010","-1")
}

/// Creator:        fengliang
/// CreatDate:      2019-12-23
/// Description:    通用配置    
/// Method          w ##class(Nur.MNISV3.Service.Config).getCommonSet("common")
ClassMethod GetCommonSet(locId, hosId = "") As %String
{
    n (locId,hosId)
    i locId="" s locId="common"
    i $d(^DHCNurPdaLocComFlag("Com",locId)) s commonFlag=^DHCNurPdaLocComFlag("Com",locId)
    e  s commonFlag="Y"     
    i commonFlag="Y" s locId="common"_hosId 
    s commId=$o(^Nur.DHCNurPdaCommSetI("locIdIndex"," "_$ZCVT(locId,"U"),""))
    i commId'="" 
    {
        s commonData=$g(^Nur.DHCNurPdaCommSetD(commId))
        s SchStartDate=$listget(commonData,3)
        s SchStartTime=$listget(commonData,4)
        s SchEndDate=$listget(commonData,5)
        s SchEndTime=$listget(commonData,6)
        s AllOutNum=$listget(commonData,7)
        s ExeAlertFlag=$listget(commonData,8)
        s InfusionLoopFlag=$listget(commonData,9)
        s VoiceFlag=$listget(commonData,10)
        s JpRecControlFlag=$listget(commonData,11)
        s PyfhControlFlag=$listget(commonData,12)
    }
    else{
        q "0^00:00^0^23:59^7^true^true^true^false^true"
    }   
    q $g(SchStartDate)_"^"_$g(SchStartTime)_"^"_$g(SchEndDate)_"^"_$g(SchEndTime)_"^"_$g(AllOutNum)_"^"_$g(ExeAlertFlag)_"^"_$g(InfusionLoopFlag)_"^"_$g(VoiceFlag)_"^"_$g(JpRecControlFlag)_"^"_$g(PyfhControlFlag)
}

/// Creator:        fengliang
/// CreatDate:      2018-12-26
/// Description:    获取主界面模块配置    
/// Other           w ##class(Nur.JSON).Encode(##class(Nur.MNISV3.Service.Config).GetModulSetByMenu("621","340"))
ClassMethod GetModulSetByMenu(locId = "", groupId = "")
{
    n (locId,groupId)
    k repeated
    s id=""
    f  s id=$o(^CT.NUR.MNIS.MainModuleD(id)) q:id=""  d
    .s moduleData=^CT.NUR.MNIS.MainModuleD(id)
    .s moduleCode=$listget(moduleData,3)
    .s sort=$listget(moduleData,4)
    .s canFlag=$listget(moduleData,5)
    .s menuId=$listget(moduleData,6)
    .i (canFlag) b
    .q:canFlag="N"
    .//默认显示标准数据，如果按科室设置之后显示科室配置
    .//s moduleLocId=$o(^CF.NUR.MNIS.MainModuleByLocI("locCodeIndex"," "_$ZCVT(locId,"U")," "_$ZCVT(moduleCode,"U"),""))
    .i ($d(repeated(moduleCode))) d
    ..s moduleIndex=repeated(moduleCode)
    ..s menuSort=$lg(moduleIndex,1),sort=$lg(moduleIndex,2) ;,id=$lg(moduleIndex,3)
    ..k moduleID(menuSort,sort,id)
    .s moduleLocId=..GetModuleByLocID("",locId,"",moduleCode)
    .i moduleLocId'="" d
    ..s moduleLocData=$g(^CF.NUR.MNIS.MainModuleByLocD(moduleLocId))
    ..s sort=$listget(moduleLocData,4)
    ..s menuId=$listget(moduleLocData,7)
    .i sort="" s sort=999999
    .s menuSort=999999
    .i menuId'=""  d
    ..s menuObj=##class(CF.NUR.MNIS.ModuleMenu).%OpenId(menuId)
    ..s menuSort=menuObj.MenuSort
    ..d menuObj.%Close()
    .s moduleID(menuSort,sort,id)=1
    .s repeated(moduleCode)=$lb(menuSort,sort,id)
    s mainObj=##class(%ListOfDataTypes).%New()
    s menuSortF=""
    f
    {
        s menuSortF=$o(moduleID(menuSortF))
        q:menuSortF=""
        s mainSubList=##class(%ListOfDataTypes).%New()
        s sortF=""
        f  
        {
            s sortF=$o(moduleID(menuSortF,sortF)) 
            q:sortF=""  
            s moduleID=""
            f  
            {
                s moduleID=$o(moduleID(menuSortF,sortF,moduleID)) 
                q:moduleID=""  
                s moduleData=$g(^CT.NUR.MNIS.MainModuleD(moduleID))
                s moduleName=$listget(moduleData,2)
                s moduleCode=$listget(moduleData,3)
                s moduleSort=$listget(moduleData,4)
                s menuId=$listget(moduleData,6)
                s moduleShowFlag="Y"
                //默认显示标准数据，如果按科室设置之后显示科室配置
                //s moduleLocId=$o(^CF.NUR.MNIS.MainModuleByLocI("locCodeIndex"," "_$ZCVT(locId,"U")," "_$ZCVT(moduleCode,"U"),""))
                s moduleLocId=..GetModuleByLocID("",locId,"",moduleCode)
                i moduleLocId'="" d
                .s moduleLocData=$g(^CF.NUR.MNIS.MainModuleByLocD(moduleLocId))
                .s moduleName=$listget(moduleLocData,2)
                .s moduleSort=$listget(moduleLocData,4)
                .s moduleShowFlag=$listget(moduleLocData,5)
                .s menuId=$listget(moduleLocData,7)
                continue:moduleShowFlag="N"
                i menuId'=""  d
                .s menuObj=##class(CF.NUR.MNIS.ModuleMenu).%OpenId(menuId)
                .s menuSort=menuObj.MenuSort
                .s menuCode=menuObj.MenuCode
                .s menuName=menuObj.MenuName
                .d menuObj.%Close()
                s mainArr=##class(%ArrayOfDataTypes).%New()
                d mainArr.SetAt(moduleName,"moduleDesc")
                d mainArr.SetAt(moduleCode,"moduleCode")
                d mainSubList.Insert(mainArr)
            }
        }
        i mainSubList.Count()'=0
        {
            s mainData=##class(%ArrayOfDataTypes).%New()
            d mainData.SetAt($g(menuName),"menuName")
            d mainData.SetAt($g(mainSubList),"mainSubList")
            d mainObj.Insert(mainData)  
        }
    }
    //q ##class(Nur.MNISV3.Common.JSON).Encode(mainObj)
    q mainObj
}

/// Creator：      EH
/// CreatDate：    2021-06-18
ClassMethod GetLocIndirectly(ByRef hospID = "", ByRef locID = "", wardID = "", admID = "", ordID = "") As %String
{
    n (hospID,locID,wardID,admID,ordID)
    i (ordID'="") d
    .s hospID=##class(Nur.MNISV3.Service.Session).GetOrdHospID(ordID)
    .s locID=##class(Nur.MNISV3.Service.Session).GetOrdLocID(ordID)
    e  i (admID'="") d
    .s hospID=##class(Nur.MNISV3.Service.Session).GetPatHospID(admID)
    .s locID=##class(Nur.MNISV3.Service.Session).GetPatLocID(admID)
    e  i (wardID'="") d
    .s hospID=##class(Nur.MNISV3.Service.Session).GetWardHospID(wardID)
    .s locID=##class(Nur.MNISV3.Service.Session).GetWardLocID(wardID)
    e  i (locID'="")&(hospID="") d
    .s hospID=##class(Nur.MNISV3.Service.Session).GetLocHospID(locID)
    q locID
}

/// Creator：      EH
/// CreatDate：    2021-08-20   
ClassMethod GetMainHospIndirectly(ByRef hospID = "", ByRef locID = "", wardID = "", admID = "", ordID = "") As %String
{
    n (hospID,locID,wardID,admID,ordID)
    d ..GetLocIndirectly(.hospID,.locID,wardID,admID,ordID)
    q ##class(Nur.MNISV3.Service.Session).GetMainHospID(hospID)
}

/// Creator：      EH
/// CreatDate：    2022-05-13      
ClassMethod GetModuleMainHospByLocID(hospID = "", locID = "", wardID = "", code = "") As %String
{
    n (hospID,locID,wardID,code)
    d ..GetLocIndirectly(.hospID,.locID,wardID)
    i ('##class(%Dictionary.MethodDefinition).%ExistsId("web.DHCBL.BDP.BDPMappingHOSP||GetDefHospIdByTableName")) q hospID
    i (code="Temperature") q ##class(web.DHCBL.BDP.BDPMappingHOSP).GetDefHospIdByTableName(##class(Nur.NIS.Common.ConstVal).#TABLEOBS,hospID,$zd(+$h,3))
    i (code="NurseOrder") q ##class(web.DHCBL.BDP.BDPMappingHOSP).GetDefHospIdByTableName(##class(Nur.NIS.Common.ConstVal).#TABLENURSESHEET,hospID,$zd(+$h,3))
    q ##class(web.DHCBL.BDP.BDPMappingHOSP).GetDefHospIdByTableName(##class(Nur.HISUI.MNIS.Config).#MAINTABLE,hospID,$zd(+$h,3))
}

/// Creator：      EH
/// CreatDate：    2021-06-18
/// Description:   取科室模块ID        
ClassMethod GetModuleByLocID(hospID = "", locID = "", wardID = "", code = "") As %String
{
    n (hospID,locID,wardID,code)
    d ..GetLocIndirectly(.hospID,.locID,wardID)
    q ##class(Nur.HISUI.MNIS.Config).GetModuleByLocID(hospID,locID,code,"N")
}

/// Creator：      EH
/// CreatDate：    2021-06-18
/// Description:   取科室消息ID     
ClassMethod GetMessageByLocID(hospID = "", locID = "", wardID = "", code = "") As %String
{
    n (hospID,locID,wardID,code)
    d ..GetLocIndirectly(.hospID,.locID,wardID)
    q ##class(Nur.HISUI.MNIS.Config).GetMessageByLocID(hospID,locID,code,"N")
}

/// Creator：      EH
/// CreatDate：    2021-06-18
/// Description:   取全局设置      
ClassMethod GetGeneralSetting(hospID = "", locID = "", wardID = "", admID = "", ordID = "") As %ListOfDataTypes
{
    n (hospID,locID,wardID,admID,ordID)
    d ..GetLocIndirectly(.hospID,.locID,wardID,admID,ordID)
    q ##class(Nur.HISUI.MNIS.Config).GetSettingObject(hospID,locID,"N")
}

/// Creator：      EH
/// CreatDate：    2021-11-09
/// Description:   取全局设置   
ClassMethod GetGeneralSettingValue(hospID = "", locID = "", wardID = "", admID = "", ordID = "", code = "") As %ListOfDataTypes
{
    n (hospID,locID,wardID,admID,ordID,code)
    d ..GetLocIndirectly(.hospID,.locID,wardID,admID,ordID)
    q ##class(Nur.HISUI.MNIS.Config).GetSettingValue(hospID,locID,code,"N")
}

/// Creator：      EH
/// CreatDate：    2021-06-18
/// Description:   取条码设置   
ClassMethod GetBarcodeSetting(hospID = "", locID = "", wardID = "") As %ListOfDataTypes
{
    n (hospID,locID,wardID)
    d ..GetLocIndirectly(.hospID,.locID,wardID)
    q ##class(Nur.HISUI.MNIS.Config).GetBarcodes(hospID,locID,"N")
}

/// Creator：      EH
/// CreatDate：    2021-06-18
/// Description:   取升级设置  
ClassMethod GetUpdateSetting(hospID = "", locID = "", wardID = "") As %ArrayOfDataTypes
{
    n (hospID,locID,wardID)
    d ..GetLocIndirectly(.hospID,.locID,wardID)
    q ##class(Nur.HISUI.MNIS.Config).GetUpdate(hospID,locID,"N")
}

/// Creator：      EH
/// CreatDate：    2021-08-25
/// Description:   取医生站设置   
ClassMethod GetDocConfigNode(hospID = "", locID = "", wardID = "", admID = "", ordID = "", code = "") As %String
{
    n (hospID,locID,wardID,admID,ordID,code)
    s hospID=..GetMainHospIndirectly(.hospID,.locID,wardID,admID,ordID)
    q ##class(web.DHCDocConfig).GetConfigNode(code,hospID)
}

/// Creator：      EH
/// CreatDate：    2021-09-01
/// Description:   取模板设置    
ClassMethod GetTemplate(hospID = "", locID = "", wardID = "", ByRef arr) As %ArrayOfDataTypes
{
    n (hospID,locID,wardID,arr)
    s ^zlf("GetTemplate")=$lb(hospID,locID,wardID,arr)
    k arr
    d ..GetLocIndirectly(.hospID,.locID,wardID)
    s object=##class(Nur.HISUI.MNIS.Config).GetTemplates(hospID,locID,"N")
    s i=0 while (1) {
        s i=object.Next(i)
        q:(i="")
        s ID=object.GetAt(i).GetAt("ID")
        s rec=##class(CF.NUR.MNIS.DepModelSet).%OpenId(ID)
        s folderID=rec.MenuId
        s arr(folderID,ID)=""
    }
    q object
}

ClassMethod GetTemplateLoc(hospID = "", locID = "", wardID = "", ByRef arr) As %ArrayOfDataTypes
{
    n (hospID,locID,wardID,arr)
    k arr

    s exist=##class(%Dictionary.MethodDefinition).%ExistsId("Nur.HISUI.MNIS.Config||GetTemplatesLoc")
    i exist s object=##class(Nur.HISUI.MNIS.Config).GetTemplatesLoc(hospID,locID,"N")
    e  s object=##class(Nur.HISUI.MNIS.Config).GetTemplates(hospID,locID,"N")
    s i=0 while (1) {
        s i=object.Next(i)
        q:(i="")
        s ID=object.GetAt(i).GetAt("ID")
        s rec=##class(CF.NUR.MNIS.DepModelSet).%OpenId(ID)
        s folderID=rec.MenuId
        s arr(folderID,ID)=""
    }
    q object
}

/// Creator：      EH
/// CreatDate：    2022-04-11
/// Description:   取设置列标题
/// Other:         w ##class(Nur.MNISV3.Service.Config).GetTemplateTitle(15,"DHCNURBRADENPGB")
ClassMethod GetTemplateTitle(admID = "", code = "") As %String
{
    n (admID,code)
    d ..GetLocIndirectly(.hospID,.locID,"",admID)
    q ##class(Nur.HISUI.MNIS.Config).GetTemplateTitle(hospID,locID,code,"N")
}

ClassMethod GetTemplateListCode(admID = "", code = "") As %String
{
    n (admID,code)
    d ..GetLocIndirectly(.hospID,.locID,"",admID)
    q ##class(Nur.HISUI.MNIS.Config).GetTemplateListCode(hospID,locID,code,"N")
}

/// Creator：      EH
/// CreatDate：    2022-04-15
/// Description:   取标准化设置
ClassMethod GetTemperatureChartItemObject(hospID = "", locID = "", wardID = "") As %ArrayOfDataTypes
{
    n (hospID,locID,wardID)
    s hospID=..GetModuleMainHospByLocID(hospID,locID,wardID,"Temperature")
    q ##class(Nur.HISUI.MNIS.Config).GetStandardizationValueObject(hospID,locID,"User.MRCObservationItem","","2544245","N")
}

/// Creator：      EH
/// CreatDate：    2022-05-06
/// Description:   取标准化设置   
ClassMethod GetTemperatureMultiItemStr(hospID = "", locID = "", wardID = "", time = "") As %String
{
    n (hospID,locID,wardID,time)
    s hospID=..GetModuleMainHospByLocID(hospID,locID,wardID,"Temperature")
    s itemStr=""
    s object=##class(Nur.HISUI.MNIS.Config).GetStandardizationValueObject(hospID,locID,"User.MRCObservationItem","","2631662,2636429","N")
    s key="" f  s key=object.Next(key) q:(key="")  d
    .s value=object.GetAt(key)
    .s valueTime=$p(value,"@",2),item=$p(value,"@",1)
    .q:(item="")||((valueTime'="")&&((","_valueTime_",")'[(","_time_",")))
    .i (itemStr'="") s itemStr=itemStr_"^"
    .s itemStr=itemStr_item
    q itemStr
}

/// Creator：      EH
/// CreatDate：    2022-05-15  
ClassMethod GetTemperaturePointStr(hospID = "", locID = "", wardID = "", times = "") As %String
{
    n (hospID,locID,wardID,times,%session)
    s points=""
    s d=$c(##class(Nur.NIS.Common.ConstVal).#TimeSplitCharDecimal)
    i $d(%session) d
    .i (times=1)!(times=2)!(times=6) s points=$tr(##class(Nur.NIS.Common.ConstVal).getTimes(times),d,",")
    e  d
    .s hospID=..GetModuleMainHospByLocID(hospID,locID,wardID,"Temperature")
    .s pointConfig=$g(^MRC("VSGenel",+hospID,"timePoint"))
    .q:(pointConfig="")
    .i (times=1) s points=$p(pointConfig,",",4)
    .i (times=2) s points=$p(pointConfig,",",2)_","_$p(pointConfig,",",4)
    .i (times=6) s points=pointConfig
    q points
}

/// Creator：      EH
/// CreatDate：    2022-05-15   
ClassMethod GetTemperatureViewVersion(hospID = "", locID = "", wardID = "") As %String
{
    n (hospID,locID,wardID)
    s hospID=..GetModuleMainHospByLocID(hospID,locID,wardID,"Temperature")
    q ##class(Nur.HISUI.MNIS.Config).GetStandardizationValueSingle(hospID,locID,"VitalSign_View_Version","N")
}

/// Creator：      EH
/// CreatDate：    2022-05-13
/// Description:   取标准化设置      
ClassMethod GetLoginFlags() As %ArrayOfDataTypes
{
    n
    s loginFlags=##class(%ArrayOfDataTypes).%New()
    s voiceFlag=..ParseFlag(##class(Nur.HISUI.MNIS.Config).GetStandardizationValueObject("","","","","2580162","N").GetAt("voiceFlag"))
    d loginFlags.SetAt(voiceFlag,"voiceFlag")
    s msgFlag=..ParseFlag(##class(Nur.HISUI.MNIS.Config).GetStandardizationValueObject("","","","","3401198","N").GetAt("msgFlag"))
    d loginFlags.SetAt(msgFlag,"msgFlag")
    s serverIPFlag=..ParseFlag(##class(Nur.HISUI.MNIS.Config).GetStandardizationValueObject("","","","","4141942","N").GetAt("serverIPFlag"))
    d loginFlags.SetAt(serverIPFlag,"serverIPFlag")
    q loginFlags
}

/// Creator：      EH
/// CreatDate：    2022-05-25       
ClassMethod GetBedListLeftScreenStr(hospID = "", locID = "", wardID = "", module = "") As %String
{
    n (hospID,locID,wardID,module)
    i (module'="") q ""
    s hospID=..GetMainHospIndirectly(.hospID,.locID,wardID)
    s screenStr=""
    s object=##class(Nur.HISUI.MNIS.Config).GetStandardizationValueObject(hospID,locID,"","","2544250","N")
    s key="" f  s key=object.Next(key) q:(key="")  d
    .s value=object.GetAt(key)
    .q:($p(value,"|",1)="")!($p(value,"|",3)="")
    .i (screenStr'="") s screenStr=screenStr_"^"
    .s screenStr=screenStr_value
    q screenStr
}

/// Creator：      EH
/// CreatDate：    2022-05-25     
ClassMethod GetToTourObject(hospID = "", locID = "") As %String
{
    n (hospID,locID)
    s hospID=..GetMainHospIndirectly(.hospID,.locID,"")
    s object=##class(Nur.HISUI.MNIS.Config).GetStandardizationValueObject(hospID,locID,"","","3132884","N")
    q object
}

/// Creator：      EH
/// CreatDate：    2022-05-27
/// Description:   取标准化设置      
ClassMethod ParseFlag(flag = "") As %String
{
    n (flag)
    s flag=$s(flag="Y":1,flag="N":0,1:flag)
    q flag
}

/// Creator：      EH
/// CreatDate：    2022-05-27
/// Description:   取标准化设置   
ClassMethod GetConfigFlags(hospID = "", locID = "", wardID = "") As %String
{
    n (hospID,locID,wardID)
    s configFlags=##class(%ArrayOfDataTypes).%New()
    s hospID=..GetModuleMainHospByLocID(hospID,locID,wardID,"Temperature")
    s leftScreenFlag=..ParseFlag(##class(Nur.HISUI.MNIS.Config).GetStandardizationValueObject(hospID,locID,"","","2551119","N").GetAt("VitalSign_Left_Screen_Flag"))
    d configFlags.SetAt(leftScreenFlag,"vitalSignLeftFilterFlag")
    q configFlags
}

/// Creator：      EH
/// CreatDate：    2022-05-27
/// Description:   取标准化设置   
ClassMethod GetModuleFlag(hospID = "", locID = "", module = "", code = "") As %String
{
    n (hospID,locID,module,code)
    s hospID=..GetModuleMainHospByLocID(hospID,locID,"",module)
    s flag=..ParseFlag(##class(Nur.HISUI.MNIS.Config).GetStandardizationValueSingle(hospID,locID,code,"N"))
    q flag
}

}
